
class IProgress
{
public:
	virtual void DoProgress(float value) = 0;
	virtual ~IProgress();
}

class FileSplitter
{
	string m_filePath;
	int m_fileNumber;


	// ProgressBar* m_progressBar;	//实现细节,具体的通知控件
	List<IProgress*> m_iprogressList; // 抽象通知机制，代替上面的具体通知控件,支持多个观察者

public:
		FileSplitter(const string& filePath, int fileNumber):
		m_filePath(filePath),
		m_fileNumber(fileNumber)
		{

		}

		void addIProgress(IProgress* iprogress)
		{
			m_iprogressList.add(iprogress);
		}

		void removeIProgress(IProgress* iprogress)
		{
			m_iprogressList.remove(iprogress);
		}

		void split()
		{
			//读取文件大小

			//分批次向小文件中写入
			for(int i = 0; i < m_fileNumber; i++)
			{
				//...
				if(m_iprogress != nullptr)
				{
					float progressValue = m_fileNumber;
					progressValue = (i + 1)/progressValue;
					onProgress(progressValue);
				}
			}
		}

	protected:
		void onProgress(float value)
		{
			List<IProgress*>::iterator start = m_iprogressList.begin();
			while（start ！= m_iprogressList.end()）
			{
				(*start)->DoProgress(value);
				start++;
			}
		}
}


//多继承只推荐一个主类继承，其他的都是接口继承
class MainForm : public Form, public IProgress
{
	TextBox* txtFilePath;
	TextBox* txtFileNumber;

	ProgressBar* progressBar;

public:
	void Button_Click()
	{
		string filePath = txtFilePath->getText();
		int number = atoi(txtFileNubmer -> getText().c_str());

		FileSplitter splitter(filePath, number);

		splitter.addIProgress(this);//订阅
		//...
		//可加入多个观察者
		//可删除多个观察者

		splitter.split();
	}

	virtual void DoProgress(float value)
	{
		progressBar->setValue(value);
	}
}

